Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve] A more universal method to detect java8 #4198

Closed
wants to merge 1 commit into from

Conversation

Shawyeok
Copy link
Contributor

@Shawyeok Shawyeok commented Feb 4, 2024

The current bookkeeper installation package's scripts in the bin directory depend on JAVA_HOME to detect whether the current Java runtime environment is Java 8. However, in some deployment scenarios, the system does not configure the JAVA_HOME environment variable. If Java 11 or a higher version is installed, running the script will result in the following error:

# yum install java-11-openjdk-devel
# bin/bookkeeper shell
JAVA_HOME not set, using java from PATH. (/usr/bin/java)
OpenJDK 64-Bit Server VM warning: Option AggressiveOpts was deprecated in version 11.0 and will likely be removed in a future release.
Unrecognized VM option 'PrintGCApplicationStoppedTime'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

This patch provides a more universal method to detect whether the runtime environment is Java 8, while avoiding the restriction of forcing users to set the JAVA_HOME variable.

…ctory depend on JAVA_HOME to detect whether the current Java runtime environment is Java 8. However, in some deployment scenarios, the system does not configure the JAVA_HOME environment variable. If Java 11 or a higher version is installed, running the script will result in the following error:

```
# yum install java-11-openjdk-devel
# bin/bookkeeper shell
JAVA_HOME not set, using java from PATH. (/usr/bin/java)
OpenJDK 64-Bit Server VM warning: Option AggressiveOpts was deprecated in version 11.0 and will likely be removed in a future release.
Unrecognized VM option 'PrintGCApplicationStoppedTime'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
```

This patch provides a more universal method to detect whether the runtime environment is Java 8, while avoiding the restriction of forcing users to set the JAVA_HOME variable.
@Shawyeok Shawyeok changed the title A more universal method to detect java8 [improve] A more universal method to detect java8 Feb 4, 2024
@lhotari
Copy link
Member

lhotari commented Feb 5, 2024

LGTM.

If there's a need to detect the major version, Pulsar uses this approach for detecting the major version: https://github.com/apache/pulsar/blob/9c7716ce12b1905cbe4c95fb87a623c70b694085/conf/pulsar_env.sh#L55-L68

@lhotari
Copy link
Member

lhotari commented Feb 8, 2024

Thanks for this PR @Shawyeok . I have already applied this change as part of the changes for fixing the CI in #4197. It was one of the problems there.
It's already in master branch:

bookkeeper/bin/common.sh

Lines 71 to 78 in 7bd91a7

detect_jdk8() {
local is_java_8=$($JAVA -version 2>&1 | grep version | grep '"1\.8')
if [ -z "$is_java_8" ]; then
echo "0"
else
echo "1"
fi
}

@Shawyeok
Copy link
Contributor Author

Shawyeok commented Feb 9, 2024

@lhotari
Thanks, I'm going to close this one.

@Shawyeok Shawyeok closed this Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants